<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let str1 = "www.baidu.com";
        let n1 = str1.indexOf("com")
        let n2 = str1.includes("com")
        console.log(n1)
        console.log(n2)
        let n3 = str1.startsWith("ww")
        console.log(n3)
        let n4 = str1.endsWith("om")
        console.log(n4)
        //加入位置参数
        let n5 = str1.startsWith("bai", 4)
        console.log("n5:", n5)

        let n6 = str1.endsWith("du", 8)//判断前8个字符串是不是以此结尾，从1开始数数的
        console.log("n6:", n5)

        //模板字符串输出
        let name = "sam";
        let age=20;
        let password = 123;
        let str2="name = "+name+" , password = "+password;
        let str3=`name=${name},password=${password}`;
        console.log(str2);
        console.log(str3);
        //在函数内使用模板字符串

        function showUser(){
            return 2020;
        }
        console.log(`我的内容是：${showUser()}.`)

        function showUser(a,b,c,d){
            return a[0]+b+a[1]+c+a[2]+d;
        }
        let name = "sam";
        let age=20;
        let password = 123;
        let out=showUser`name=${name},age=${age},password=${password}`
        console.log("我的内容是："+out+".")
        console.log(`我的内容是：${out}.`)


    </script>
</body>

</html>